<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common :: copyCommon"></head>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>盲盒后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo" style="font-size:18px; font-weight: bold;">盲盒后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <!-- <ul class="layui-nav layui-layout-left">
          <li class="layui-nav-item"><a href="">控制台</a></li>
          <li class="layui-nav-item"><a href="">商品管理</a></li>
          <li class="layui-nav-item"><a href="">用户</a></li>
          <li class="layui-nav-item">
            <a href="javascript:;">其它系统</a>
            <dl class="layui-nav-child">
              <dd><a href="">邮件管理</a></dd>
              <dd><a href="">消息管理</a></dd>
              <dd><a href="">授权管理</a></dd>
            </dl>
          </li>
        </ul> -->
        <ul class="layui-nav layui-layout-right">
            <!-- <li class="layui-nav-item">
              <a href="javascript:;">
                <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">
                  <span th:text="${user.userName}"></span>
              </a>
              <dl class="layui-nav-child">
                <dd><a href="">基本资料</a></dd>
                <dd><a href="">安全设置</a></dd>
              </dl>
            </li> -->
            <li class="layui-nav-item"><a th:href="@{/login/logOut}">退出系统</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree menu-nav"  lay-filter="test">
                <li class="layui-nav-item" th:each="rootItem, itemStat : ${user.menuList}" th:if="${rootItem.pid == null}">
                    <a class="" href="javascript:;" th:text="${rootItem.menuName}"></a>
                    <dl class="layui-nav-child">
                        <dd th:each="childItem, childItemStat : ${user.menuList}" th:if="${childItem.pid != null && childItem.pid == rootItem.id}">
                            <a class="childMenu" href="javascript:;" th:id="${childItem.menuKey}" th:attr="menuKey=${childItem.menuKey}" target="targetText" th:text="${childItem.menuName}"></a>
                        </dd>
                    </dl>
                </li>
            </ul>

        </div>
    </div>

    <div class="layui-body">
        <iframe src="" width="100%" height="99.7%" frameborder="0" name="targetText" id="pageIframe"></iframe>
    </div>

    <!-- 底部固定区域 -->
    <div class="layui-footer">
        © studio49.com
    </div>
</div>
<script>
	layui.use('element', function(){
	  var element = layui.element;
	});

	//子菜单绑定点击事件
	$(".childMenu").each(function() {
        $(this).bind("click", function() {
            var menuKey = $(this).attr("menuKey");
            window.location.href = rootPath + "/index#" + menuKey;
        });
    });

//url改变事件
$(window).bind('hashchange', function() {
    var urlPa =  decodeURI(document.location.hash);
    var menuKey = (urlPa=="" ? "":urlPa.substring(1));

    if (menuKey != "") {
        toUrl(menuKey);
    }
 });

//页面进入，加载对应menuKey的数据
 window.onload = function(){
    var urlPa =  decodeURI(window.location.hash);

    if (urlPa != "") {
        var menuKey = urlPa.substring(1);
        toUrl(menuKey);
        signMenu(menuKey);
    }else{
    	$("#pageIframe").attr("src", "homePage");
    }
 }

 //加载数据
 function toUrl(menuKey) {
     var url = rootPath + '/sys/menu/findMenuByKey';
     var menu = CommnUtil.ajax(url, {
         "menuKey" : menuKey
     }, "json");
     if (menu != null) {
         suburl = menu.url;
     }
     if (suburl != null && suburl !='' && suburl != 'null' && suburl != undefined) {
     	$("#pageIframe").attr("src", suburl);
     }
 }

 //标记菜单，点中转态
function signMenu(menuKey){
	$("#" + menuKey).addClass("layui-this");
	$("#" + menuKey).parent().parent().parent().addClass("layui-nav-itemed");
}

</script>
</body>
</html>
